package com.linsir.core.object;

import com.linsir.aop.AopContext;
import com.linsir.aop.MetaObjectIntercept;
import com.linsir.model.MetaField;

/**
 * @author yuxiaolin
 * @title: ObjectIntercept
 * @projectName linsir-mu
 * @description: TODO
 * @date 2021/12/3 4:33 PM
 */

public class ObjectIntercept extends MetaObjectIntercept {

    @Override
    public String deleteBefore(AopContext ac) throws Exception {
        Integer id = ac.record.getInt("id");
        // 删除对象关联元字段属性
        MetaField.dao.deleteByObjectId(id);
        // 删除对象关联的所有字典 慎重，会导致误删同表字段
        // String ds = ac.record.getStr("data_source");
        // String table = ac.record.getStr("table_name");
        // String dict = EovaConfig.getProps().get("main_dict_table");
        // Db.use(ds).update("delete from " + dict + " where object = ?", table);

        return null;
    }

}
